<template>
	<view>
		<dsl-navbar title="个人资料" bgTopImg="#ffffff" isBack="true"></dsl-navbar>
		<view class="">

			<view class="align-center  bg-white rowsb padding solid-bottom">
				<view class="text-gray">头像</view>
				<view class="align-center">
					<image @click="avatarUpload()" class="user_image" :src="avatar?avatar:''"></image>
					<text class="cuIcon-right text-gray"></text>
				</view>
			</view>
			<view class="align-center bg-white  solid-bottom padding rowsb">
				<view class="align-center">
					<view class="text-gray">昵称</view>
					<input v-model="nickname" type="text" class="margin-left" placeholder="请输入" />
				</view>
				<view class="cuIcon-right"></view>
			</view>
			<view class="align-center bg-white solid-bottom padding rowsb">
				<view class="text-gray">性别</view>
				<view>
					<picker mode="selector" :range="list" @change="bindPickerChange">
						<image v-if="gender==''" style="width: 40rpx;height: 40rpx;" src="/static/my/youjian.png">
						</image>
						<view class="" v-if="gender!=''">{{gender ||'请选择'}}</view>
					</picker>
				</view>
			</view>
			<view class="align-center bg-white  padding rowsb">
				<view class="align-center">
					<view class="text-gray">年龄</view>
					<input v-model="nickname" type="text" class="margin-left" placeholder="请输入" />
				</view>
				<view class="cuIcon-right"></view>
			</view>
			<view class="align-center  bg-white solid-bottom padding rowsb margin-top ">
				<view class="align-center">
					<view class="text-gray">身高</view>
					<input v-model="nickname" type="text" class="margin-left" placeholder="请输入" />
				</view>
				<view class="cuIcon-right"></view>
			</view>
			<view class="align-center bg-white  padding rowsb">
				<view class="align-center">
					<view class="text-gray">年龄</view>
					<input v-model="nickname" type="text" class="margin-left" placeholder="请输入" />
				</view>
				<view class="cuIcon-right"></view>
			</view>
			<view class="align-center bg-white  padding rowsb margin-top">
				<view class="align-center">
					<view class="text-gray">个人优势</view>
				</view>
				<view class="cuIcon-right"></view>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		updateUser,
		getUserInfo
	} from '@/common/path.js'
	export default {
		data() {
			return {
				list: ['男', '女'],
				gender: '', //性别
				avatar: '', //头像
				nickname: '', //昵称
				userInfo:{},//用户信息
			}
		},
		//生命周期函数
		onReady() {},
		onLoad() {},
		onShow() {
			this.getUserInfo() //用户信息
		},
		methods: {
			//修改用户信息
			updateUser() {
				let v = this
				let data = {
					userName:v.userName,
					avatar:v.avatar,//头像
				}
				v.Http.POST(updateUser, data)
					.then((res) => {
						if (res.code == 0) {
							setTimeout(() => {
								v.$tools.back()
							}, 1000)
							v.$tools.showToast2(res.msg)
						} else {
							v.$tools.showToast(res.msg)
						}
					})
			},
			//获取用户信息
			getUserInfo(){
				let data  ={
					id:uni.getStorageSync('userInfo').id
				}
				this.Http.POST(getUserInfo,data)
				.then((res)=>{
					if(res.code == 0 ){
						console.log('[用户信息]',res);
						this.userInfo = res.data
					}
				})
			},
		},
		computed: {},
		components: {}
	}
</script>

<style scoped>
	.user_image {
		width: 98rpx;
		height: 98rpx;
		background: #eeeeee;
		border-radius: 50%;
		opacity: 1;
	}

	.submit {
		width: 658rpx;
		height: 90rpx;
		background: #1573E7;
		opacity: 1;
		border-radius: 45rpx;
		text-align: center;
		line-height: 90rpx;
		color: white;
		margin-top: 200rpx;
	}

	.text-gray {
		color: #9AA2B5;
	}

	page {
		background: #F7F6FA;
	}
</style>
